﻿using DotNetCore.CAP;
using FluentEmail.Core;
using MediatR;
using Microsoft.CodeAnalysis.Emit;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MyTask.Tasking.Applicaiton.IntegrationEvents
{
    public class SubscriberService : ISubscriberService, ICapSubscribe
    {
        IMediator _mediator;
        IFluentEmail _email;
        public SubscriberService(IMediator mediator, IFluentEmail email)
        {
            _mediator = mediator;
            _email = email;
        }
        [CapSubscribe("TaskCreated")]
        public async Task TaskCreatedAsync(TaskCreatedIntegrationEvent @event)
        {
            //发送邮件
           var result= await _email
                                        .To("qiangxianghui@163.com")
                                        .Subject("test email subject")
                                        .Body("This is the email body")
                                        .SendAsync();
        }
    }
}
